<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Flanvas - Dragging</title>

<!-- 
<script src="/js/jquery/jquery-1.4.2.min.js" type="text/javascript"></script> 
-->
<script src="../flanvas.r25.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {
	_f.traceDiv = document.getElementById("trace");
	//_f.clearTraceOnFrame = false;
	_f.traceDraw = false;
	stage.canvas = document.getElementById('myCanvas');
	stage.fps = 24;
	
	var circ = new Sprite();
	circ.graphics.beginFill(0x0000ff);
	circ.graphics.drawCircle(0, 0, 40);
	circ.graphics.endFill();
	circ.x = 100;
	circ.y = 100;
	
	stage.addChild(circ);
	
	var clickProps;
	function contMouseDownHandler(event) {
		clickProps = {'x':event.currentTarget.x,'y':event.currentTarget.y,'mouseX':stage.mouseX,'mouseY':stage.mouseY};
		stage.addEventListener(MouseEvent.MOUSE_MOVE, contMouseMoveHandler);
		stage.addEventListener(MouseEvent.MOUSE_UP, contMouseUpHandler);
	}
	function contMouseMoveHandler(event) {
		circ.x = clickProps.x + (stage.mouseX - clickProps.mouseX);
		circ.y = clickProps.y + (stage.mouseY - clickProps.mouseY);
	}
	function contMouseUpHandler(event) {
		stage.removeEventListener(MouseEvent.MOUSE_MOVE, contMouseMoveHandler);
		stage.removeEventListener(MouseEvent.MOUSE_UP, contMouseUpHandler);
	}
	
	circ.addEventListener(MouseEvent.MOUSE_DOWN, contMouseDownHandler);
}
</script>
</head>

<body>

<div id="trace" width="250" height="350" style="position:absolute; right:0; text-align:right;"></div>
<canvas id="myCanvas" width="550" height="400" style="position:absolute; left:0; top:0;"></canvas>

</body>
</html>
